/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author luisramirezmartinez 
 *
 */
@Entity
@Table(name = "tbl_perfiles")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblPerfiles.findAll", query = "SELECT t FROM TblPerfiles t"),
    @NamedQuery(name = "TblPerfiles.findByIdperfil", query = "SELECT t FROM TblPerfiles t WHERE t.idperfil = :idperfil"),
    @NamedQuery(name = "TblPerfiles.findByPerfil", query = "SELECT t FROM TblPerfiles t WHERE t.perfil = :perfil"),
    @NamedQuery(name = "TblPerfiles.findByNombre", query = "SELECT t FROM TblPerfiles t WHERE t.nombre = :nombre"),
    @NamedQuery(name = "TblPerfiles.findByDescripcion", query = "SELECT t FROM TblPerfiles t WHERE t.descripcion = :descripcion"),
    @NamedQuery(name = "TblPerfiles.findByEstatus", query = "SELECT t FROM TblPerfiles t WHERE t.estatus = :estatus")})
public class TblPerfiles implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id_perfil")
    private Integer idperfil;
    @Basic(optional = false)
    @Column(name = "Perfil")
    private String perfil;
    @Column(name = "Nombre")
    private String nombre;
    @Column(name = "Descripcion")
    private String descripcion;
    @Column(name = "Estatus")
    private Boolean estatus;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idperfil")
    private Collection<TblPerfilesUsuarios> tblPerfilesUsuariosCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tblperfilesIdperfil")
    private Collection<TblPantallasPerfiles> tblPantallasPerfilesCollection;
  
    public TblPerfiles(){
        this.estatus=false;
        this.perfil="";
        this.tblPantallasPerfilesCollection= new ArrayList<TblPantallasPerfiles>();

    }

    public TblPerfiles(Integer idperfil) {
        this.idperfil = idperfil;
        this.estatus=false;
        this.tblPantallasPerfilesCollection= new ArrayList<TblPantallasPerfiles>();
    }

    public TblPerfiles(Integer idperfil, String perfil) {
        this.idperfil = idperfil;
        this.perfil = perfil;
        this.estatus=false;
        this.tblPantallasPerfilesCollection= new ArrayList<TblPantallasPerfiles>();
    }

    public Integer getIdperfil() {
        return idperfil;
    }

    public void setIdperfil(Integer idperfil) {
        Integer oldIdperfil = this.idperfil;
        this.idperfil = idperfil;
        changeSupport.firePropertyChange("idperfil", oldIdperfil, idperfil);
    }

    public String getPerfil() {
        return perfil;
    }

    public void setPerfil(String perfil) {
        String oldPerfil = this.perfil;
        this.perfil = perfil;
        changeSupport.firePropertyChange("perfil", oldPerfil, perfil);
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        String oldNombre = this.nombre;
        this.nombre = nombre;
        changeSupport.firePropertyChange("nombre", oldNombre, nombre);
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        String oldDescripcion = this.descripcion;
        this.descripcion = descripcion;
        changeSupport.firePropertyChange("descripcion", oldDescripcion, descripcion);
    }

    public Boolean getEstatus() {
        return estatus;
    }

    public void setEstatus(Boolean estatus) {
        Boolean oldEstatus = this.estatus;
        this.estatus = estatus;
        changeSupport.firePropertyChange("estatus", oldEstatus, estatus);
    }

    @XmlTransient
    public Collection<TblPerfilesUsuarios> getTblPerfilesUsuariosCollection() {
        return tblPerfilesUsuariosCollection;
    }

    public void setTblPerfilesUsuariosCollection(Collection<TblPerfilesUsuarios> tblPerfilesUsuariosCollection) {
        this.tblPerfilesUsuariosCollection = tblPerfilesUsuariosCollection;
    }

    @XmlTransient
    public Collection<TblPantallasPerfiles> getTblPantallasPerfilesCollection() {
        return tblPantallasPerfilesCollection;
    }

    public void setTblPantallasPerfilesCollection(Collection<TblPantallasPerfiles> tblPantallasPerfilesCollection) {
        Collection<TblPantallasPerfiles> oldTblPantallasPerfilesCollection=this.tblPantallasPerfilesCollection;
        this.tblPantallasPerfilesCollection = tblPantallasPerfilesCollection;
        changeSupport.firePropertyChange("tblPantallasPerfilesCollection", oldTblPantallasPerfilesCollection, tblPantallasPerfilesCollection);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idperfil != null ? idperfil.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblPerfiles)) {
            return false;
        }
        TblPerfiles other = (TblPerfiles) object;
        if ((this.idperfil == null && other.idperfil != null) || (this.idperfil != null && !this.idperfil.equals(other.idperfil))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return  idperfil + " "+ nombre+ " "+descripcion;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
